package com.szwistar.common.luaj;

import org.luaj.vm2.Globals;
import org.luaj.vm2.LoadState;
import org.luaj.vm2.compiler.LuaC;
import org.luaj.vm2.lib.Bit32Lib;
import org.luaj.vm2.lib.CoroutineLib;
import org.luaj.vm2.lib.PackageLib;
import org.luaj.vm2.lib.StringLib;
import org.luaj.vm2.lib.TableLib;
import org.luaj.vm2.lib.jse.JseBaseLib;
import org.luaj.vm2.lib.jse.JseIoLib;
import org.luaj.vm2.lib.jse.JseMathLib;
import org.luaj.vm2.lib.jse.JseOsLib;
import org.luaj.vm2.lib.jse.LuajavaLib;

/**
 * 兼容 jnlua
 */
public class LuaState extends Globals {
    public LuaState() {
        LoadState.install(this);
        LuaC.install(this);
    }

    public void openLibs() {
        load(new JseBaseLib());
        load(new PackageLib());
        load(new Bit32Lib());
        load(new TableLib());
        load(new StringLib());
        load(new CoroutineLib());
        load(new JseMathLib());
        load(new JseIoLib());
        load(new JseOsLib());
        load(new LuajavaLib());
    }
}
